<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<style>
    .item-box{
        border: 1px solid #9fbbb4; overflow: hidden; padding:0  3px 0 3px;margin-bottom: 3px;
    }
    .item-box .item-box-title {
        float: left;text-align: center;  font-weight: 800;border-right: 1px solid #9fbbb4;padding: 0 2px 0 0;
    }
   .item-box-right{
        float: left;text-align: center; padding: 0 2px 0 0;border-left: 1px solid #9fbbb4;
    }
    .form-contanier{
        /*height: 50px; line-height: 50px;*/padding: 0 0 0 3px;width: 950px;
    }
    .form-contanier label{
        font-weight: 400;
    }
    .form-contanier label{
        width: 100px;
    }
    .form-contanier span{
        display: inline-block;
        min-width: 130px;
    }
    .form-contanier input{
        width: 150px;
    }
</style>
<div style="padding: 20px" id="item_container">
    <c:if test="${fn:length(ret)<1}">
        暂无上传资料
    </c:if>
    <c:forEach var="item" items="${ret}" varStatus="retStatus">
        <form id="item_form">
            <div class="item-box">
                <div  class="item-box-title" >
                        ${item.key.name}
                </div>
                <div style="float: left" class="item-box-center">
                    <input  type="hidden" value="${item.value[0].groupId}" name="groupId">
                    <div class="form-contanier">
                        <%--遍历该类型的所有资料类型 例如身份证下面的所有资料类型--%>
                        <c:forEach var="type" items="${item.key.children}" varStatus="status" >
                            <div id="up_item" style="display: inline-block;width: 300px;float: left;min-height:99px;line-height:99px;">
                                <label> ${type.name}:</label>
                                <span class="up_item">
                                <c:choose>
                                    <%--图片类型--%>
                                    <c:when test="${'fileselect'==type.type}">
                                        <%--遍历该类型用户上传的所有资料 例如用户上传的所有身份证资料--%>
                                        <input type="hidden" name="typeId" value="${type.id}" >
                                        <input type="hidden" name="id" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${obj.id}</c:if></c:forEach>" >
                                        <c:set var="oldUrls" value=""></c:set>
                                        <input id="iconvalues${status.index}${retStatus.index}" name="iconvalues"   type="hidden" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${oldUrls}${obj.url}|</c:if></c:forEach>">
                                        <c:set var="oldUrls" value=""></c:set>
                                        <sys:ckfinder input="iconvalues${status.index}${retStatus.index}" type="files" uploadPath="/sys/material/materialUpload" selectMultiple="true"/>
                                    </c:when>
                                    <%--radio类型--%>
                                    <c:when test="${'radiobox'==type.type}">
                                        <input type="hidden" name="typeId" value="${type.id}" >
                                        <input type="hidden" name="id" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${obj.id}</c:if></c:forEach>" >
                                        <c:forEach var="keyValue" items="${type.keyValues}">
                                            ${keyValue.label}<input  name="radiovalue" type="radio" style="width: auto"  <c:forEach var="obj" items="${item.value}"><c:if test="${obj.value==keyValue.value}">checked="checked"</c:if></c:forEach>   value="${keyValue.value}" >
                                        </c:forEach>
                                    </c:when>
                                    <%--dateselect类型--%>
                                    <c:when test="${'dateselect'==type.type}">
                                        <input type="hidden" name="typeId" value="${type.id}" >
                                        <input type="hidden" name="id" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${obj.id}</c:if></c:forEach>" >
                                        <input name="value" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${obj.value}</c:if></c:forEach>" type="text" readonly="readonly" class="Wdate "  onclick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowClear:false});"/>
                                    </c:when>
                                    <%--普通文本类型--%>
                                    <c:otherwise>
                                        <input type="hidden" name="typeId" value="${type.id}" >
                                        <input type="hidden" name="id" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${obj.id}</c:if></c:forEach>" >
                                        <input type="text" name="value" value="<c:forEach var="obj" items="${item.value}"><c:if test="${obj.typeId==type.id}">${obj.value}</c:if></c:forEach>">
                                    </c:otherwise>
                                </c:choose>
                            </span>
                            </div>

                        </c:forEach>
                    </div>
                </div>

                <c:choose>
                    <c:when test="${view==true}">
                    </c:when>
                    <c:otherwise>
                        <div  class="item-box-right" style="float: right">
                            <div style="">
                                &nbsp; <button type="button" class="btn btn-primary item-save" >保存</button>
                                &nbsp; <button type="button" class="btn btn-danger item-del" >删除</button>
                            </div>
                        </div>
                    </div>
                </c:otherwise>
                </c:choose>
        </form>
    </c:forEach>
</div>
<div id="template" class="hide">
    <c:forEach var="item" items="${typeList}" varStatus="retStatus">
        <form id="item_form" data-id="${item.id}">
            <div class="item-box" style="border: 1px solid red">
                <div  class="item-box-title" >
                        ${item.name}
                </div>
                <div style="float: left" class="item-box-center">
                    <div class="form-contanier">
                            <%--遍历该类型的所有资料类型 例如身份证下面的所有资料类型--%>
                        <c:forEach var="type" items="${item.children}" varStatus="status" >
                                <div id="up_item" style="display: inline-block;width: 300px;float: left;height:99px;line-height:99px;">
                                    <label> ${type.name}:</label>
                                    <span class="up_item">
                                        <c:choose>
                                            <%--图片类型--%>
                                            <c:when test="${'fileselect'==type.type}">
                                                <%--遍历该类型用户上传的所有资料 例如用户上传的所有身份证资料--%>
                                                <input type="hidden" name="typeId" value="${type.id}" >
                                                <c:set var="oldUrls" value=""></c:set>
                                                <input id="iconvalues${status.index}" name="iconvalues"   type="hidden" value="">
                                                <c:set var="oldUrls" value=""></c:set>
                                                <sys:ckfinder input="iconvalues${status.index}" type="files" uploadPath="/sys/material/materialUpload" selectMultiple="true"/>
                                            </c:when>
                                            <%--radio类型--%>
                                            <c:when test="${'radiobox'==type.type}">
                                                <input type="hidden" name="typeId" value="${type.id}" >
                                                <c:forEach var="keyValue" items="${type.keyValues}">
                                                    ${keyValue.label}<input  name="radiovalue" type="radio" style="width: auto"   value="${keyValue.value}" >
                                                </c:forEach>
                                            </c:when>
                                            <%--dateselect类型--%>
                                            <c:when test="${'dateselect'==type.type}">
                                                <input type="hidden" name="typeId" value="${type.id}" >
                                                <input name="value" value="" type="text" readonly="readonly" class="Wdate "  onclick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowClear:false});"/>
                                            </c:when>
                                            <%--普通文本类型--%>
                                            <c:otherwise>
                                                <input type="hidden" name="typeId" value="${type.id}" >
                                                <input type="hidden" name="id" value="" >
                                                <input type="text" name="value" value="">
                                            </c:otherwise>
                                        </c:choose>
                                    </span>
                                </div>
                        </c:forEach>
                    </div>
                </div>
                <div  class="item-box-right" style="float: right;">
                    <div style="">
                        &nbsp; <button type="button" class="btn btn-primary item-save" >保存</button>
                        &nbsp; <button type="button" class="btn btn-danger item-del" >删除</button>
                    </div>
                </div>
            </div>
        </form>
    </c:forEach>
</div>
